package cn.bytecollege.controller;

import cn.bytecollege.constant.Resource;
import cn.bytecollege.entity.RoomCategory;
import cn.bytecollege.service.RoomCategoryService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name="RoomCategoryListController",value="/roomCategoryList")
public class RoomCategoryListController extends HttpServlet {
    private RoomCategoryService roomCategoryService=null;
    public RoomCategoryListController(){
        roomCategoryService=new RoomCategoryService();
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //调用service方法
        List<RoomCategory> list= roomCategoryService.findAll();
        request.setAttribute("list",list);
        request.getRequestDispatcher(Resource.PAGE_LOCATION+"/roomCategoryList.jsp").forward(request,response);
    }
}
